{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Remove Consecutive Nodes that Sum to 0\n",
    "\n",
    "[The Original Question](https://mp.weixin.qq.com/s/i_gx422EumTL7xqeWTrAOQ)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question\n",
    "\n",
    "Given a linked list of integersm remove all consecutive nodes that sum up to 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Node:\n",
    "    def __init__(self, value, next=None):\n",
    "        self.value = value\n",
    "        self.next = next\n",
    "        pass\n",
    "    \n",
    "    pass\n",
    "\n",
    "\n",
    "def removeConsecutiveSumTo0(node: Node) -> Node:\n",
    "    # Fill this in. \n",
    "    pass\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    node = Node(10, Node(5, Node(-3, Node(-3, Node(1, Node(4, Node(-4)))))))\n",
    "    node = removeConsecutiveSumTo0(node)\n",
    "    while node is not None:\n",
    "        print(node.value),\n",
    "        node = node.next\n",
    "        pass\n",
    "    pass"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
